C code for PEGetNParams, PEGetNthParam, and PESetNthParam

If the report being accessed by the Report Engine uses a SQL database table that is based on a stored procedure, you may wish to examine and change the parameters of that procedure. The following code demonstrates how to use the PEGetNParams, PEGetNthParam, and PESetNthParam functions to work with stored procedures:

PEGetNParams

short            nParams;
    // Number of parameters in stored procedure
nParams = PEGetNParams(Job);
if (nParams < 0){
    // Handle error
}

PEGetNthParam

short            paramN;
    // The parameter we are interested in
HANDLE    textHandle;
short        textLength;
char        *textString;
paramN = 0;
    // First parameter in stored procedure
if (!PEGetNthParam(Job, paramN, &textHandle, &textLength)){
    // Handle error
}
    // Allocate buffer
textString = (char*)malloc(textLength);
    // Retrieve string
if (!PEGetHandleString(textHandle, textString, textLength)){
    // Handle error
}
    // textString now contains the value of
    // the first parameter in the stored procedure.

PESetNthParam

short            paramN;
    // The parameter to be changed
char szParamValue [] = "1005";
    // Pass numeric value to parameter
paramN = 1;    
    // Change second parameter in stored procedure
if (!PESetNthParam(Job, paramN, szParamValue)){
    // Handle error
}


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com